package com.ocelot.san.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.ocelot.san.dto.Role;
import com.ocelot.san.repository.RoleRepository;

@Service
public class RoleService {
	
	@Resource
	private RoleRepository roleRepository;
	
	public void save(Role role) {
		roleRepository.save(role);
	}
	
	public Role findById(Long id) {
		return roleRepository.findOne(id);
	}

	public void delete(Long id) {
		roleRepository.delete(id);
	}
	
	public List<Role> fetchAll() {
		return roleRepository.findAll(new Sort(Sort.Direction.ASC, "name"));
	}
}
